﻿namespace JT1078.Gateway
{
    /// <summary>
    /// 下发终端指令流水号
    /// </summary>
    public class TerminalCommandSerialNo
    {
        /// <summary>
        /// 流水号
        /// </summary>
        private static int _serialNo = 0;
        /// <summary>
        /// 生成当前流水号
        /// </summary>
        /// <returns></returns>
        public static ushort New()
        {
            if (_serialNo >= 0xFFFF)
            {
                _serialNo = 0;
            }
            else
            {
                System.Threading.Interlocked.Increment(ref _serialNo);
            }
            return (ushort)_serialNo;
        }
    }
}
